# Contributor: Danct12 <danct12@disroot.org>
# Contributor: Asriel Dreemurr <asriel.danctnix@gmail.com>
# Maintainer: Danct12 <danct12@disroot.org>
pkgname=bullet
pkgver=3.25
pkgrel=2
pkgdesc="A 3D Collision Detection and Rigid Body Dynamics Library for games and animation"
url="https://pybullet.org/Bullet/phpBB3/"
arch="all"
license="Zlib"
makedepends="
	cmake
	doxygen
	font-dejavu
	glu-dev
	graphviz-dev
	mesa-dev
	py3-numpy-dev
	py3-setuptools
	python3-dev
	samurai
	"
options="!check" # cannot build tests
subpackages="$pkgname-dev $pkgname-doc py3-$pkgname:py3"
source="bullet3-$pkgver.tar.gz::https://github.com/bulletphysics/bullet3/archive/$pkgver.tar.gz
	ppc64le.patch
	"
builddir="$srcdir/bullet3-$pkgver"

build() {
	CFLAGS="$CFLAGS -O2 -DNDEBUG -flto=auto" \
	CXXFLAGS="$CXXFLAGS -O2 -DNDEBUG -flto=auto" \
	cmake -B build -G Ninja -Wno-dev \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=None \
		-DBUILD_PYBULLET=ON \
		-DBUILD_PYBULLET_NUMPY=ON \
		-DBUILD_SHARED_LIBS=True \
		-DBUILD_UNIT_TESTS=OFF \
		-DBULLET2_MULTITHREADING=ON \
		-DCMAKE_SKIP_RPATH=ON \
		-DINSTALL_EXTRA_LIBS=ON \
		-DINSTALL_LIBS=ON \
		-DUSE_DOUBLE_PRECISION=ON
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	# Install LICENSE
	install -Dm644 "$builddir"/LICENSE.txt "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
	install -Dm644 "$builddir"/docs/GPU_rigidbody_using_OpenCL.pdf "$pkgdir"/usr/share/doc/bullet/GPU_rigidbody_using_OpenCL.pdf
	install -Dm644 "$builddir"/docs/Bullet_User_Manual.pdf "$pkgdir"/usr/share/doc/bullet/Bullet_User_Manual.pdf
	install -Dm644 "$builddir"/docs/BulletQuickstart.pdf "$pkgdir"/usr/share/doc/bullet/BulletQuickstart.pdf
}

py3() {
	pkgdesc="$pkgdesc (python module)"

	amove usr/lib/python3*
}

sha512sums="
7086e5fcf69635801bb311261173cb8d173b712ca1bd78be03df48fad884674e85512861190e45a1a62d5627aaad65cde08c175c44a3be9afa410d3dfd5358d4  bullet3-3.25.tar.gz
39902a1c147cb866bbbade32a2a3eaa0e855ed8203cd55de30fab8c6c43c5f15dea706b4d2123938b34b82105767fa919a4505c473d8139a28193111c967bc76  ppc64le.patch
"
